﻿using MediatR;
using RBAC.LuFang.API.Application.Command.RoleCommand;
using RBAC.LuFang.Domain;
using RBAC.LuFang.Domin.Services;

namespace RBAC.LuFang.API.Application.CommandHandlers.RoleHandler
{
    public class RoleCreateCommandHandler : IRequestHandler<RoleCreateCommand, int>
    {
        private readonly IRoleService _roleService;

        public RoleCreateCommandHandler(IRoleService roleService)
        {
            _roleService = roleService;
        }

        public async Task<int> Handle(RoleCreateCommand request, CancellationToken cancellationToken)
        {
            //var roleModel=new Role() { RoleName = request.RoleName };
            return await _roleService.AddRole(new Role() { RoleName = request.RoleName });
        }
    }
}
